package com.jms.web.controller.jms.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.jms.common.filter.utils.poi.ExcelUtil;
import com.jms.web.controller.jms.domain.QuestionSchedule;
import com.jms.web.controller.jms.service.IQuestionScheduleService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jms.common.annotation.Log;
import com.jms.common.core.controller.BaseController;
import com.jms.common.core.domain.AjaxResult;
import com.jms.common.enums.BusinessType;
import com.jms.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 问题处理记录Controller
 * 
 * @author drx
 * @date 2024-04-29
 */
@RestController
@RequestMapping("/system/schedule")
public class QuestionScheduleController extends BaseController
{
    @Resource
    private IQuestionScheduleService questionScheduleService;

    /**
     * 查询问题处理记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuestionSchedule questionSchedule)
    {
        startPage();
        List<QuestionSchedule> list = questionScheduleService.selectQuestionScheduleList(questionSchedule);
        return getDataTable(list);
    }

    /**
     * 查询问题处理记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:list')")
    @PostMapping("/getList")
    public TableDataInfo getList(@RequestBody QuestionSchedule questionSchedule)
    {
        startPage();
        List<QuestionSchedule> list = questionScheduleService.selectQuestionScheduleList(questionSchedule);
        return getDataTable(list);
    }

    /**
     * 导出问题处理记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:export')")
    @Log(title = "问题处理记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuestionSchedule questionSchedule)
    {
        List<QuestionSchedule> list = questionScheduleService.selectQuestionScheduleList(questionSchedule);
        ExcelUtil<QuestionSchedule> util = new ExcelUtil<QuestionSchedule>(QuestionSchedule.class);
        util.exportExcel(response, list, "问题处理记录数据");
    }

    /**
     * 获取问题处理记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(questionScheduleService.selectQuestionScheduleById(id));
    }

    /**
     * 新增问题处理记录
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:add')")
    @Log(title = "问题处理记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody QuestionSchedule questionSchedule)
    {
        return toAjax(questionScheduleService.insertQuestionSchedule(questionSchedule));
    }

    /**
     * 修改问题处理记录
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:edit')")
    @Log(title = "问题处理记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody QuestionSchedule questionSchedule)
    {
        return toAjax(questionScheduleService.updateQuestionSchedule(questionSchedule));
    }

    /**
     * 删除问题处理记录
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:remove')")
    @Log(title = "问题处理记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(questionScheduleService.deleteQuestionScheduleByIds(ids));
    }
}
